/**
 * 生成二维码
 * package com.xdap.init.utils;
 * <p>
 * import com.google.zxing.BarcodeFormat;
 * import com.google.zxing.EncodeHintType;
 * import com.google.zxing.WriterException;
 * import com.google.zxing.common.BitMatrix;
 * import com.google.zxing.qrcode.QRCodeWriter;
 * import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
 * import com.itextpdf.io.image.ImageDataFactory;
 * import com.itextpdf.kernel.geom.PageSize;
 * import com.itextpdf.kernel.pdf.PdfDocument;
 * import com.itextpdf.kernel.pdf.PdfWriter;
 * import com.itextpdf.layout.Document;
 * import com.itextpdf.layout.borders.Border;
 * import com.itextpdf.layout.element.Image;
 * import com.itextpdf.layout.element.Paragraph;
 * import com.itextpdf.layout.element.Table;
 * import com.itextpdf.layout.properties.TextAlignment;
 * import com.itextpdf.layout.properties.UnitValue;
 * import com.itextpdf.layout.properties.VerticalAlignment;
 * <p>
 * import javax.imageio.ImageIO;
 * import java.awt.image.BufferedImage;
 * import java.io.ByteArrayInputStream;
 * import java.io.ByteArrayOutputStream;
 * import java.io.File;
 * import java.io.IOException;
 * import java.util.HashMap;
 * import java.util.Map;
 * <p>
 * public class QRCodeToPDF {
 * public static void main(String[] args) throws WriterException, IOException {
 * <p>
 * <p>
 * <p>
 * <p>
 * int backgroundColor = 0xFFFFFF; // 白色
 * int foregroundColor = 0x000000; // 黑色
 * <p>
 * String qrCodeText = "https://www.baidu.com";
 * String encoding = "www.baidu.com";
 * int qrCodeWidth = 200;
 * int qrCodeHeight = 200;
 * <p>
 * // 生成二维码
 * QRCodeWriter qrCodeWriter = new QRCodeWriter();
 * Map<EncodeHintType, ErrorCorrectionLevel> hints = new HashMap<>();
 * hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
 * BitMatrix bitMatrix = qrCodeWriter.encode(qrCodeText, BarcodeFormat.QR_CODE, qrCodeWidth, qrCodeHeight, hints);
 * <p>
 * BufferedImage bufferedImage = new BufferedImage(qrCodeWidth, qrCodeHeight, BufferedImage.TYPE_INT_RGB);
 * for (int y = 0; y < qrCodeHeight; y++) {
 * for (int x = 0; x < qrCodeWidth; x++) {
 * bufferedImage.setRGB(x, y, bitMatrix.get(x, y) ? foregroundColor : backgroundColor);
 * }
 * }
 * <p>
 * <p>
 * // 将BufferedImage转换为iText Image
 * ByteArrayOutputStream baos = new ByteArrayOutputStream();
 * ImageIO.write(bufferedImage, "png", baos);
 * Image qrCodeImage = new Image(ImageDataFactory.create(baos.toByteArray()));
 * <p>
 * // 创建PDF并添加二维码和编码
 * PdfWriter pdfWriter = new PdfWriter(new File("example.pdf"));
 * PdfDocument pdfDocument = new PdfDocument(pdfWriter);
 * Document document = new Document(pdfDocument, PageSize.A4);
 * <p>
 * // 使用表
 * Table table = new Table(UnitValue.createPercentArray(new float[]{1, 2})).useAllAvailableWidth();
 * table.addCell(qrCodeImage);
 * <p>
 * Paragraph encodingParagraph = new Paragraph(encoding)
 * .setFontSize(14);
 * table.addCell(encodingParagraph);
 * <p>
 * // 将表格添加到PDF文档中
 * document.add(table);
 * <p>
 * // 关闭文档
 * document.close();
 * System.out.println("QR code and encoding added to PDF");
 * }
 * }
 **/